#include #include using namespace std; int stringLength(char s[]) { int result = 0; while(s[result] != '\0') { result++; } return result; } int stringCompare(char s1[], char s2[]) { int result = 0; int i = 0; //case insensitive while(s1[i] != '\0' && s2[i] != '\0' && result == 0) { if(toupper(s1[i]) > toupper(s2[i])) { result = 1; } else if(toupper(s1[i]) < toupper(s2[i])) { result = -1; } i++; } if(s1[i] != '\0') { result = 1; } if(s2[i] != '\0') { result = -1; } return result; } void main() { //char s1[100]; ////ignores leading whitespace ////stops at first whitespace after non-whitespace //cin >> s1; //cout << s1 << endl; // //cin.ignore(cin.rdbuf()->in_avail()); // ////bounds protection ////reads whitespace ////does not ignore leading whitespace //cin.getline(s1,100,'b'); //cout << s1 << endl; ////cout << stringLength(s1) << endl; ////cout << stringLength("this is a test") << endl; //for(int c = 0; c < 256; c++) //{ // cout << c << "\t" << (char)c << endl; //} char s1[100]; char s2[100]; cin >> s1; cin >> s2; if(stringCompare(s1,s2) == 0) { cout << "They are the same strings" << endl; } else { cout << "They are NOT the same strings" << endl; } }